#pragma once
#include <string>
#include <vector>
#include "../core/nodes/classtype.h"
#include "../code/fieldcode.h"
#include "fixclients.h"

class SemanticVisitorData;

class Field
{
 public:
	     /*! Owner class name
		  */
		std::string m_classname;
		std::vector<std::string>  m_clients;
		ClassTypeNode *           m_type;
		FeatureDeclarationType    m_decltype;
		std::string               m_realname;

		FieldCode                 m_code;
		FeatureSpecName      *    m_node;
 public:
		inline Field() {}
	    inline Field(const std::string & classname,
			         const std::vector<std::string> & clients,
					 ClassTypeNode * type,
					 FeatureDeclarationType dtype,
					 const std::string & realname
					)
		{
			m_clients=clients;
			m_type=type;
			m_decltype=dtype;
			m_classname=classname;
			m_realname=realname;
		}
		/** Fixes clients of string
			\param[in] class, that supposed to be client
		 */
		inline void fixClients(const std::string & className) { ::fixClients(m_clients,className); }

		inline void setNode(FeatureSpecName * node)
		{
			m_node=node;
		}
		inline FeatureSpecName * node() const
		{
			return m_node;
		}
		/** Checks, whether method is available from class
		 */
		bool isAvailable(const std::string & className, SemanticVisitorData * data);
		/** Returns a real name of field
		 */
		inline const std::string & realName() const {
			return m_realname;
		}
		/** Returns a common name for method
			\param[out] name name of method
			\param[out] descriptor used descriptor of method
		 */
		void getCommonCompilableSignature(std::string & name, std::string & descriptor);
		/** Returns a common name for method
			\param[out] name name of method
			\param[out] descriptor used descriptor of method
		 */
		void getFullCompilableSignature(std::string & name, std::string & descriptor);
		/** Returns a method ref info
			\param[out] classname used class name
			\param[out] name  name of method
			\param[out] descriptor used descriptor
		 */
		void getRefInfo(std::string & classname,std::string & name, std::string & descriptor);

		/*! Used code for field
		 */
		inline FieldCode & code()
		{
			return m_code;
		}
};